/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.hnilica.emailer;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
import java.util.Timer;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author swosh
 */
public class Main {
    private static final int day = 24 * 60 * 60 * 1000;

    private final Timer timer = new Timer();
    private final TermChecker emailChecker = new TermChecker();
    private final SimpleDateFormat pattern = new SimpleDateFormat("yyyy.MM.dd G HH:mm:ss Z");
    private Date startTime;



    public Main(String startTimeString){
        try {
            startTime = pattern.parse(startTimeString); //should at five
        } catch (ParseException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void start() {
        timer.scheduleAtFixedRate(emailChecker, startTime, day);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Main main = new Main("2010.11.16 AD 05:48:00 +0100");
        main.start();

    }

}
